<template>
	<view class="page" style="padding-bottom: 50rpx;">
		<view class="topVue">
			<view class="safeVue" :style="{ height: statusBarHeight + 'rpx' }"></view>
			<view class="flex align-center padding-row30" :style="{ height: barHeight + 'rpx', top: statusBarHeight + 'rpx' }" @click="$tools.back()">
				<image src="../../static/back.png" style="width: 48rpx; height: 48rpx;"></image>
				<text style="line-height: 1; color: #454545; font-weight: 600; font-size: 32rpx; padding-left: 20rpx;">{{detail.name}}</text>
			</view>
		</view>
		<view :style="{ height: statusBarHeight + barHeight + 'rpx' }"></view>
		<image :src="obj.url" mode="widthFix" style="width: 100%;"></image>
		<view class="name">产品： {{obj.name}}</view>
		<view class="name">产品价格： ￥{{obj.price}}</view>
		<view class="name">{{obj.description}}</view>
		<!-- <view class="name">
			<u-checkbox v-model="checked" active-color="#D37430">是否寄存</u-checkbox>
		</view> -->
		<view class="btn margin50" @click="submit()">确定</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				obj: {},
				statusBarHeight: 0,
				barHeight: 0,
				checked: false,
			}
		},
		onLoad(option) {
			let that = this;
			wx.getSystemInfo({
				success(res) {
					let deviceWidth = wx.getSystemInfoSync().windowWidth
					that.statusBarHeight = Number(res.statusBarHeight) * ( 750 / deviceWidth ) 
					let menuButtonInfo = wx.getMenuButtonBoundingClientRect()
					let barHeight = menuButtonInfo.height + (menuButtonInfo.top - res.statusBarHeight) * 2
					that.barHeight = Number(barHeight) * ( 750 / deviceWidth )
				},
			});
			this.getList()
		},
		methods: {
			async getList(){
				const res = await this.$request("/api/WeChat/goodList", {}, "GET")
				if(res.code===200) {
					this.obj = res.data
					console.log(this.obj)
				}
			},
			async submit(){
				const res = await this.$request("/api/WeChat/partnerGoodsOrder", {
					goodId: this.obj.id,
					deposit: this.checked ? 1 : 0
				}, 'POST', "application/x-www-form-urlencoded")
				if(res.code===200) {
					this.$u.toast("操作成功")
					setTimeout(()=>{
						this.$tools.back()
					}, 1000)
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.topVue {
		width: 100%;
		background: #fff;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 99;
		.safeVue {
			width: 100%;
		}
	}
	.name {
		padding: 30rpx 0 0 30rpx;
		font-weight: 600;
		font-size: 32rpx;
	}
	.btn {
		width: 670rpx;
		height: 88rpx;
		background: #D37430;
		border-radius: 44rpx;
		line-height: 88rpx;
		color: #fff;
		text-align: center;
		font-weight: 600;
	}
</style>